package com.tanhua.server.controller;

import com.tanhua.server.service.SoundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author To my left is the dog
 * @date 2021/2/28 15:49
 */
@RestController
@RequestMapping("/peachblossom")
public class SoundController {

    @Autowired
    private SoundService soundService;

    /*POST/peachblossom
    * 发送语音（保存语音）*/
    @PostMapping
    public ResponseEntity saveSound(MultipartFile soundFile) throws IOException {
        try {
            return soundService.saveSound(soundFile);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

    /*桃花传音-接收语音（学生实战）
    * GET/peachblossom*/
    @GetMapping
    public ResponseEntity acceptSound(){
        return soundService.acceptSound();
    }
}
